/**
 * 功能描述 收费行编辑
 */

define(function(require, exports, module) {
	var Grid = require("grid");
	var enmu = require("enums");
	var Dialog = require("dialog");
	var applyGridEvents = require("../handler/applyGridEvents");

	var instance = {
		initComponent : function(params, widget) {
			var pergrid = new Grid(
					{
						parentNode : ".J-pergrid",
						model : {
							id : "memberRegisterApplyGrid",
							head : {
								items : [ {
									id : "applyAdd",
									type : "button",
									text : "新增",
									handler : function() {
										if(widget.get("type") == "NonMember" && 
												widget.get("form").getValue("tourType") == ""){
											Dialog.alert({
												tip : "提示",
												content : "请先选择散客类型！"
											})
											return false;
										}else{
											applyGridEvents.addApply(widget);
										}
									}
								} ]
							},
							columns : [{
								name : "signUpRegister.personalInfo.idNumber",
								label : "身份证号",
							},{
								name : "signUpRegister.personalInfo.name",
								label : "姓名",
							},{
								name : "signUpRegister.personalInfo.sex",
								label : "性别",
								format : function(data, row) {
									return data.value || "";
								},
							},{
								name : "signUpRegister.personalInfo.mobilePhone",
								label : "手机号",
							},{
								name : "signUpRegister.travelContract.memberCertificates",
								label : "会员证号",
								format : function(data, row) {
									if(row.travelContract){
										return row.travelContract.member.personalInfo.idNumber+"-"+row.travelContract.member.personalInfo.name+
										"-"+row.travelContract.productRule.product.name+"-"+row.travelContract.memberCertificates;
									}else if(row.signUpRegister && row.signUpRegister.travelContract !=null && row.signUpRegister.travelContract.memberCertificates != ""){
										return row.signUpRegister.travelContract.member.personalInfo.idNumber+"-"+row.signUpRegister.travelContract.member.personalInfo.name+
										"-"+row.signUpRegister.travelContract.productRule.product.name+"-"+row.signUpRegister.travelContract.memberCertificates;
									}else{
										return "";
									}
								},
							},{
								name : "signUpRegister.contactName",
								label : "紧急联系人"
							},{
								name : "signUpRegister.contactPhone",
								label : "紧急联系人电话"
							},{
								name : "show",
								label : "操作",
								format : "button",
								formatparams : [{
									id : "delete",
									icon : "icon-remove",
									handler : function(index, data, rowEle) {
										applyGridEvents.deleteMem(data,widget,index);
									}
								} ]
							} ]
						}
					});
			widget.set("pergrid", pergrid);
		}
	};
	module.exports = instance;
});
